<?php
Authenticate::requireTechnic();
if($_SERVER['REQUEST_METHOD']=='GET'){
	View::display('technic/article.add');
}
else if($_SERVER['REQUEST_METHOD']=='POST'){
	$db = Db::getInstance();
	$db->autocommit(false);
	$query = sprintf("INSERT INTO Article(title, description, detail, author) VALUES('%s','%s','%s','technic')",
			$db->real_escape_string($_POST['title']),
			$db->real_escape_string($_POST['description']),
			$db->real_escape_string($_POST['detail']));
	if(!$db->query($query)){
		throw new Exception($db->error);
	}
	$db->commit();
	header("Location: old.php?page=technic/article");
}